/*
 *                    COPYRIGHT NOTICE
 *
 *           This code is copyright protected by Freedom Inc.
 *
 *              2001-2012 All Rights Are Reserved
 */
package com.freedom.oldsong.tag;

import java.io.IOException;

import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import com.freedom.oldsong.util.CommonWebContextUtil;
import com.freedom.oldsong.util.LanguageUtil;



/**
 * @author steven.wang
 *
 */
public class I18nTag extends SimpleTagSupport {

	/**
	 * @name serialVersionUID
	 * @type long
	 */
	private static final long serialVersionUID = 1L;
	
    //private final Log log = LogFactory.getLog(I18nTag.class);
    
    /**
     * @name key
     * @type String
     */
    private String key;
   
    /**
     * (non-Javadoc)
     * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
     */
    @Override
    public void doTag() throws JspException, IOException {
    	  JspContext jc = this.getJspContext();
    	  PageContext pc = (PageContext)jc;
    	  String value = LanguageUtil.getText(key, (String)CommonWebContextUtil.getFromSession(LanguageUtil.LANGUAGE));
    	  JspWriter out = pc.getOut();
    	  out.print(value);   	
    }

	/**
	 * @name getKey
	 *
	 * @return    
	 * String     
	 * @throws 
	*/
	public String getKey() {
		return key;
	}

	/**
	 * @name setKey
	 *
	 * @param key    
	 * void     
	 * @throws 
	*/
	public void setKey(String key) {
		this.key = key;
	}
}
